var username=localStorage.getItem("username");
var token=localStorage.getItem("token");
var userid=localStorage.getItem("userid");
$(function(){
	$("#preRecvTime").datetimepicker({lang:'ch',
		timepicker:false,
		format:'Y-m-d',
		formatDate:'Y-m-d'
	});

	var paramMap = params();
	var id = paramMap['id'];
	$("#backList").click(function(){
		var url=server_url+'/orderManage/list.do';
		tl_config.last_url=url;
		tl_config.loadToWorkArea(url);
	});

	debugger
	$.ajax({
		type : 'GET',
		contentType : 'application/json',
		async : false,
		data : {
			orderId : id,
			token:token
		},
		url : server_url+'/rest/tea/order/getOrderInfo.do?ran='+Math.random(),
		dataType : 'json',
		success : function(data) {
			if (data.retCode == "0000") {
				pasteData(data.data);
			} else{
				easyDialog.open({
					container:{
						header:'温馨提示',
						content:data.retMsg
					},
					autoClose : 2000
				});
			}
		}
	});
	
});

function isEmpty(data){
	if(data==null||data==undefined||data.length==0){
		return true;
	}else{
		return false;
	}
}
function pasteData(data){
	debugger
	console.log(data);
    //var order=data.order.data;

    $("#id").val(data.id);
	$("#orderCode").text(data.orderno);
	$("#orderStatusName").text(data.status);
	$("#teausername").val(data.teaUserAddr.userName);
	$("#usersName").text(data.teaFrontusers.usersname);
	$("#preRecvTime").val(data.addtime);
	$("#price").val(data.totalunit);
	$("#recvPrice").val(data.recvPrice);
	$("#area").val(data.teaUserAddr.userArea + data.teaUserAddr.userAddr);
	$("#phone").val(data.teaUserAddr.userPhone);

	$("#picturePath1").attr("src",data.teaProduct.pic);
				
	$("<tr><td style='padding: 0px 0;'>"+data.teaProduct.productname+"</td> " +
			"<td style='padding: 0px 0;'>"+data.conut+"</td>  " +
			"<td style='padding: 0px 0;'>"+data.teaProduct.teaPrice+"</td>  " +
			"</tr>").appendTo($("#productTable"));

};
function back(){
	var url=server_url+'orderManage/list.do';
	tl_config.loadToWorkArea(url);
}

//刷新当前页面
var reloadFn = function(){
	window.location.reload();
};
